/*
ID: guoxu1
PROG: ariprog
LANG: C++
*/
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

const int max_length = 250 * 250 + 250 * 250 + 1;
bool F[max_length] = {false};

#define cin fin
#define cout fout

int main()
{
  ifstream fin( "ariprog.in" );
  ofstream fout( "ariprog.out" );
  
  int n = 0, m = 0;
  cin >> n >> m;
  
  vector<int> seq;
  for( int i = 0; i <= m; i++ )
  {
    for( int j = i; j <= m; j++ )
    {
      int v = i * i + j * j;
      F[v] = true;
      seq.push_back( v );
    }
  }
  std::sort( seq.begin(), seq.end() );
  std::unique( seq.begin(), seq.end() );
  
  int max_num = m * m * 2;
  int max_diff = max_num / ( n - 1 );
  bool solution = false;
  for( int d = 1; d <= max_diff; d++ )
  {
    int up_bound = max_num - d * ( n - 1 );
    for( size_t s = 0; s < seq.size() && seq[s] <= up_bound; s++ )
    {
      int k = seq[s];
      bool found = true;
      int next = k;
      for( int t = 1; t < n; t++ )
      {
        next += d;
        if( !F[next] )
        {
          found = false;
          break;
        }
      }
      if( found )
      {
        cout << k << " " << d << endl;
        solution = true;
      }
    }
  }
  if( !solution )
  {
    cout << "NONE" << endl;
  }
  return 0;
}
